import Vue from 'vue'
import VueRouter from 'vue-router'
//引入首页的路由
import layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home/dashboard'
  },
  {
    path: '/home',
    name: 'home',
    component: layout,
    meta: { title: '首页', icon: 'icon-panel', type: '2' },
    children: [
      { path: "dashboard", name: "dashboard", component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue'), meta: { title: '仪表盘', type: "2" } },
      { path: "data", name: "data", component: () => import(/* webpackChunkName: "data" */ '../views/dashboard/data.vue'), meta: { title: '设备数据', type: "2" } }
    ]
  },
  {
    path: '/device',
    name: 'device',
    component: layout,
    meta: { title: '设备', icon: 'icon-luyouqi', type: '2' },
    children: [
      { path: "gateway", name: "gateway", component: () => import(/* webpackChunkName: "gateway" */ '../views/device/gateway.vue'), meta: { title: '网关', type: "2" } },
      { path: "grouplist", name: "grouplist", component: () => import(/* webpackChunkName: "grouplist" */ '../views/device/groupList.vue'), meta: { title: '设备群组', type: "2" } },
      { path: "sensorlist", name: "sensorlist", component: () => import(/* webpackChunkName: "sensorlist" */ '../views/device/sensorList.vue'), meta: { title: '传感器列表', type: "2" } },
    ]
  },
  {
    path: '/fee',
    name: 'fee',
    component: layout,
    meta: { title: '计费', icon: 'icon-fyxx', type: '2' },
    children: [
      { path: "feedetail", name: "feedetail", component: () => import(/* webpackChunkName: "feedetail" */ '../views/fee/FeeDetail.vue'), meta: { title: '账户信息', type: "2" } },
      { path: "feerecharge", name: "feerecharge", component: () => import(/* webpackChunkName: "feerecharge" */ '../views/fee/FeeRecharge.vue'), meta: { title: '充值记录', type: "2" } },
      { path: "feeusage", name: "feeusage", component: () => import(/* webpackChunkName: "feeusage" */ '../views/fee/FeeUsage.vue'), meta: { title: '使用记录', type: "2" } },
    ]
  },
  {
    path: '/measurement',
    name: 'measurement',
    component: layout,
    meta: { title: '测量类型', icon: 'icon-signal', type: '2' },
    children: [
      { path: "measurementadd", name: "Measurementadd", component: () => import(/* webpackChunkName: "Measurementadd" */ '../views/measurement/measurementAdd.vue'), meta: { title: '添加测量类型', type: "2" } },
      { path: "measurementlist", name: "measurementlist", component: () => import(/* webpackChunkName: "measurementlist" */ '../views/measurement/measurementList.vue'), meta: { title: '测量类型列表', type: "2" } },
    ]
  },
  {
    path: '/security',
    name: 'security',
    component: layout,
    meta: { title: '安全', icon: 'icon-anquan', type: '1' },
    children: [
      { path: "securityadd", name: "securityadd", component: () => import(/* webpackChunkName: "securityadd" */ '../views/security/securityAdd.vue'), meta: { title: '添加密钥', type: "1" } },
      { path: "securitylist", name: "securitylist", component: () => import(/* webpackChunkName: "securitylist" */ '../views/security/securityList.vue'), meta: { title: '密钥列表', type: "1" } },
    ]
  },
  {
    path: '/account',
    name: 'account',
    component: layout,
    meta: { title: '账号', icon: 'icon-account', type: '1' },
    children: [
      { path: "addaccount", name: "addaccount", component: () => import(/* webpackChunkName: "addaccount" */ '../views/account/AddAccount.vue'), meta: { title: '添加账号', type: "1" } },
      { path: "listaccount", name: "listaccount", component: () => import(/* webpackChunkName: "listaccount" */ '../views/account/ListAccount.vue'), meta: { title: '账号列表', type: "1" } },
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {
    path: '*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  },
]

const router = new VueRouter({
  routes
})

export default router